home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / obero / oberon_lib.lha / oberon-a / source1.lha / source / Amiga / GadTools.mod < prev    next >
Text File  |  1994-08-08  |  25KB  |  736 lines

  1. (***************************************************************************
  2.  
  3.      $RCSfile: GadTools.mod $
  4.   Description: Interface to gadtools.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.2 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 01:11:04 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1989-1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A interface Copyright © 1994, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. ***************************************************************************)
  21.  
  22. MODULE GadTools;
  23.  
  24. (*
  25. ** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
  26. ** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
  27. ** $V- OvflChk       $Z- ZeroVars
  28. *)
  29.  
  30. IMPORT
  31.   E := Exec, U := Utility, G := Graphics, I := Intuition, SYS := SYSTEM;
  32.  
  33.  
  34. (*
  35. **      $VER: gadtools.h 39.9 (19.8.92)
  36. **
  37. **      gadtools.library definitions
  38. *)
  39.  
  40. (* -----------------------------------------------------------------------*)
  41.  
  42. (*  The kinds (almost classes) of gadgets in the toolkit.  Use these
  43.     identifiers when calling CreateGadgetA() *)
  44.  
  45. CONST
  46.  
  47.   genericKind *    = 0;
  48.   buttonKind *     = 1;
  49.   checkBoxKind *   = 2;
  50.   integerKind *    = 3;
  51.   listViewKind *   = 4;
  52.   mxKind *         = 5;
  53.   numberKind *     = 6;
  54.   cycleKind *      = 7;
  55.   paletteKind *    = 8;
  56.   scrollerKind *   = 9;
  57. (* Kind number 10 is reserved *)
  58.   sliderKind *     = 11;
  59.   stringKind *     = 12;
  60.   textKind *       = 13;
  61.  
  62.   numKinds *       = 14;
  63.  
  64. (* -----------------------------------------------------------------------*)
  65.  
  66. CONST
  67.  
  68. (*  'Or' the appropriate set together for your Window IDCMPFlags: *)
  69.  
  70.   arrowIdcmp *      =
  71.     { I.idcmpGadgetUp, I.idcmpGadgetDown, I.idcmpIntuiTicks, I.idcmpMouseButtons };
  72.  
  73.   buttonIdcmp *     = { I.idcmpGadgetUp };
  74.   checkBoxIdcmp *   = { I.idcmpGadgetUp };
  75.   integerIdcmp *    = { I.idcmpGadgetUp };
  76.   listViewIdcmp *   =
  77.     { I.idcmpGadgetUp, I.idcmpGadgetDown, I.idcmpMouseMove } + arrowIdcmp;
  78.  
  79.   mxIdcmp *         = { I.idcmpGadgetDown };
  80.   numberIdcmp *     = {};
  81.   cycleIdcmp *      = { I.idcmpGadgetUp };
  82.   paletteIdcmp *    = { I.idcmpGadgetUp };
  83.  
  84. (*  Use ArrowIdcmp + ScrollerIdcmp if your scrollers have arrows: *)
  85.   scrollerIdcmp *   =
  86.     { I.idcmpGadgetUp, I.idcmpGadgetDown, I.idcmpMouseMove };
  87.   sliderIdcmp *     =
  88.     { I.idcmpGadgetUp, I.idcmpGadgetDown, I.idcmpMouseMove };
  89.   stringIdcmp *     = { I.idcmpGadgetUp };
  90.  
  91.   textIdcmp *       = {};
  92.  
  93. (* -----------------------------------------------------------------------*)
  94.  
  95. TYPE
  96.  
  97.   VisualInfo * = CPOINTER TO RECORD END;
  98.  
  99. (*  Generic NewGadget used by several of the gadget classes: *)
  100.  
  101.   NewGadgetPtr * = CPOINTER TO NewGadget;
  102.   NewGadget * = RECORD
  103.     leftEdge *,
  104.     topEdge *    : INTEGER;       (*  gadget position *)
  105.     width *,
  106.     height *     : INTEGER;       (*  gadget size *)
  107.     gadgetText * : E.STRPTR;      (*  gadget label *)
  108.     textAttr *   : G.TextAttrPtr; (*  desired font for gadget label *)
  109.     gadgetID *   : E.UWORD;       (*  gadget ID *)
  110.     flags *      : SET;           (*  see below *)
  111.     visualInfo * : VisualInfo;    (*  Set to retval of GetVisualInfo() *)
  112.     userData *   : E.APTR;        (*  gadget UserData *)
  113.   END; (* NewGadget *)
  114.  
  115.  
  116. CONST
  117.  
  118. (* flags control certain aspects of the gadget.  The first five control
  119.  * the placement of the descriptive text.  Each gadget kind has its default,
  120.  * which is usually placeTextLeft.  Consult the autodocs for details.
  121.  *)
  122.  
  123.   placeTextLeft *  = 0;  (* Right-align text on left side *)
  124.   placeTextRight * = 1;  (* Left-align text on right side *)
  125.   placeTextAbove * = 2;  (* Center text above *)
  126.   placeTextBelow * = 3;  (* Center text below *)
  127.   placeTextIn *    = 4;  (* Center text on *)
  128.  
  129.   ngHighLabel *    = 5;  (* Highlight the label *)
  130.  
  131. (* -----------------------------------------------------------------------*)
  132.  
  133. TYPE
  134.  
  135. (* Fill out an array of these and pass that to CreateMenus(): *)
  136.  
  137.   NewMenuPtr * = CPOINTER TO NewMenu;
  138.   NewMenu * = RECORD
  139.     type *          : SHORTINT; (*  See below *)
  140.     (* Compiler inserts a PAD byte here *)
  141.     label *         : E.STRPTR; (*  Menu's label *)
  142.     commKey *       : E.STRPTR; (*  MenuItem Command Key Equiv *)
  143.     flags *         : E.WSET;   (*  Menu or MenuItem flags (see note) *)
  144.     mutualExclude * : SET;      (*  MenuItem MutualExclude word *)
  145.     userData *      : E.APTR;   (*  For your own use, see note *)
  146.   END; (* NewMenu *)
  147.  
  148. CONST
  149.  
  150. (* Needed only by inside im* definitions below *)
  151.   menuImage * = -128;
  152.  
  153. (* type determines what each NewMenu structure corresponds to.
  154.  * for the nmTitle, nmItem, and nmSub values, label should
  155.  * be a text string to use for that menu title, item, or sub-item.
  156.  * For imItem or imSub, set label to point at the Image structure
  157.  * you wish to use for this item or sub-item.
  158.  * NOTE: At present, you may only use conventional images.
  159.  * Custom images created from Intuition image-classes do not work.
  160.  *)
  161.   nmTitle *        = 1;
  162.   nmItem *         = 2;
  163.   nmSub *          = 3;
  164.  
  165.   imItem *         = nmItem + menuImage;
  166.   imSub *          = nmSub  + menuImage;
  167.  
  168. (* The NewMenu array should be terminated with a NewMenu whose
  169.  * type equals nmEnd.
  170.  *)
  171.   nmEnd * = 0;                  (* End of NewMenu array *)
  172.  
  173. (* Starting with V39, GadTools will skip any NewMenu entries whose
  174.  * ype field has the nmIgnore bit set.
  175.  *)
  176.   nmIgnore * = 64;
  177.  
  178.  
  179. (* nm_Label should be a text string for textual items, a pointer
  180.  * to an Image structure for graphical menu items, or the special
  181.  * constant nmBarlabel, to get a separator bar.
  182.  *)
  183.   nmBarLabel *     = SYS.VAL(E.STRPTR, -1);
  184.  
  185.  
  186. (*  The nmFlags field is used to fill out either the Menu.flags or
  187.     MenuItem.flags field.  Note that the sense of the menuEnabled or
  188.     itemEnabled bit is inverted between this use and Intuition's use,
  189.     in other words, NewMenus are enabled by default.  The following
  190.     labels are provided to disable them: *)
  191.   nmMenuDisabled * = I.menuEnabled;
  192.   nmItemDisabled * = I.itemEnabled;
  193.  
  194. (* New for V39:  nmCommandString.  For a textual MenuItem or SubItem,
  195.  * point commKey at an arbitrary string, and set the nmCommandString
  196.  * flag.
  197.  *)
  198.   nmCommandString * = I.commSeq;
  199.  
  200. (* The following are pre-cleared (commSeq, itemText, and highxxx are set
  201.  * later as appropriate):
  202.  * Under V39, the commSeq flag bit is not cleared, since it now has
  203.  * meaning.
  204.  *)
  205.   nmFlagMask *     = -({ I.commSeq, I.itemText } + I.highFlags);
  206.   nmFlagMaskV39 *  = -({I.itemText} + I.highFlags);
  207.  
  208.  
  209. (*  You may choose among checkIt, menuToggle, and checked.
  210.     Toggle-select menuitems are of type checkIt | menuToggle, along
  211.     with checked if currently selected.  Mutually exclusive ones
  212.     are of type checkIt, and possibly checked too.  The nmMutualExclude
  213.     is a bit-wise representation of the items excluded by this one,
  214.     so in the simplest case (choose 1 among n), these flags would be
  215.     ~1, ~2, ~4, ~8, ~16, etc.  See the Intuition Menus chapter. *)
  216.  
  217. (* A UserData pointer can be associated with each Menu and MenuItem structure.
  218.  * The CreateMenus() call allocates space for a UserData after each
  219.  * Menu or MenuItem (header, item or sub-item).  You should use the
  220.  * GTMENU_USERDATA() or GTMENUITEM_USERDATA() macro to extract it.
  221.  *)
  222.  
  223. (*
  224. #define GTMENU_USERDATA(menu) ( * ( (APTR * )(((struct Menu * )menu)+1) ) )
  225. #define GTMENUITEM_USERDATA(menuitem) ( * ( (APTR * )(((struct MenuItem * )menuitem)+1) ) )
  226.  
  227. (* Here is an old one for compatibility.  Do not use in new code! *)
  228. #define MENU_USERDATA(menuitem) ( * ( (APTR * )(menuitem+1) ) )
  229. *)
  230.  
  231. (*  These return codes can be obtained through the gtmnSecondaryError tag *)
  232.   menuTrimmed *  = 00000001H;      (* Too many menus, items, or subitems,
  233.                                            menu has been trimmed down *)
  234.   menuInvalid *  = 00000002H;      (* Invalid NewMenu array *)
  235.   menuNoMem *    = 00000003H;      (* Out of memory *)
  236.  
  237. (*------------------------------------------------------------------------*)
  238.  
  239. (* Starting with V39, checkboxes and mx gadgets can be scaled to your
  240.  * specified gadget width/height.  Use the new cbScaled or mxScaled
  241.  * tags, respectively.  Under V37, and by default in V39, the imagery
  242.  * is of the following fixed size:
  243.  *)
  244.  
  245. CONST
  246.  
  247. (* MX gadget default dimensions: *)
  248.   mxWidth * = 17;
  249.   mxHeight * = 9;
  250.  
  251. (* Checkbox default dimensions: *)
  252.   checkboxWidth * = 26;
  253.   checkboxHeight * = 11;
  254.  
  255. (* -----------------------------------------------------------------------*)
  256.  
  257. CONST
  258.  
  259. (* Tags for GadTools functions: *)
  260.  
  261.   tagBase *           = U.tagUser + 80000H;
  262.  
  263.   viNewWindow *       = tagBase+1;  (* Unused *)
  264.   viNWTags *          = tagBase+2;  (* Unused *)
  265.  
  266.   private0            = tagBase+3;  (* (private) *)
  267.  
  268.   cbChecked *         = tagBase+4;  (* State of checkbox *)
  269.  
  270.   lvTop *             = tagBase+5;  (* Top visible one in listview *)
  271.   lvLabels *          = tagBase+6;  (* List to display in listview *)
  272.   lvReadOnly *        = tagBase+7;  (* TRUE if listview is to be
  273.                                      * read-only
  274.                                      *)
  275.   lvScrollWidth *     = tagBase+8;  (* Width of scrollbar *)
  276.  
  277.   mxLabels *          = tagBase+9;  (* NULL-terminated array of labels *)
  278.   mxActive *          = tagBase+10; (* Active one in mx gadget *)
  279.  
  280.   txText *            = tagBase+11; (* Text to display *)
  281.   txCopyText *        = tagBase+12; (* Copy text label instead of
  282.                                      * referencing it
  283.                                      *)
  284.  
  285.   nmNumber *          = tagBase+13; (* Number to display *)
  286.  
  287.   cyLabels *          = tagBase+14; (* NULL-terminated array of labels *)
  288.   cyActive *          = tagBase+15; (* The active one in the cycle gad *)
  289.  
  290.   paDepth *           = tagBase+16; (* Number of bitplanes in palette *)
  291.   paColor *           = tagBase+17; (* Palette color *)
  292.   paColorOffset *     = tagBase+18; (* First color to use in palette *)
  293.   paIndicatorWidth *  = tagBase+19; (* Width of current-color indicator *)
  294.   paIndicatorHeight * = tagBase+20; (* Height of current-color indicator *)
  295.  
  296.   scTop *             = tagBase+21; (* Top visible in scroller *)
  297.   scTotal *           = tagBase+22; (* Total in scroller area *)
  298.   scVisible *         = tagBase+23; (* Number visible in scroller *)
  299.   scOverlap *         = tagBase+24; (* Unused *)
  300.  
  301. (*  tagBase+25 through tagBase+37 are reserved *)
  302.  
  303.   slMin *             = tagBase+38; (* Slider min value *)
  304.   slMax *             = tagBase+39; (* Slider max value *)
  305.   slLevel *           = tagBase+40; (* Slider level *)
  306.   slMaxLevelLen *     = tagBase+41; (* Max length of printed level *)
  307.   slLevelFormat *     = tagBase+42; (* Format string for level *)
  308.   slLevelPlace *      = tagBase+43; (* Where level should be placed *)
  309.   slDispFunc *        = tagBase+44; (* Callback for number calculation
  310.                                      * before display
  311.                                      *)
  312.  
  313.   stString *          = tagBase+45; (* String gadget's displayed string *)
  314.   stMaxChars *        = tagBase+46; (* Max length of string *)
  315.  
  316.   inNumber *          = tagBase+47; (* Number in integer gadget *)
  317.   inMaxChars *        = tagBase+48; (* Max number of digits *)
  318.  
  319.   mnTextAttr *        = tagBase+49; (* MenuItem font TextAttr *)
  320.   mnFrontPen *        = tagBase+50; (* MenuItem text pen color *)
  321.  
  322.   bbRecessed *        = tagBase+51; (* Make BevelBox recessed *)
  323.  
  324.   visualInfo *        = tagBase+52; (* result of VisualInfo call *)
  325.  
  326.   lvShowSelected *    = tagBase+53; (* show selected entry beneath
  327.                 * listview, set tag data = NULL for display-only, or pointer
  328.                 * to a string gadget you've created
  329.                 *)
  330.   lvSelected *        = tagBase+54; (* Set ordinal number of selected
  331.                                      * entry in the list
  332.                                      *)
  333.   reserved1           = tagBase+56; (* Reserved for future use *)
  334.  
  335.   txBorder *          = tagBase+57; (* Put a border around
  336.                                      * Text-display gadgets
  337.                                      *)
  338.   nmBorder *          = tagBase+58; (* Put a border around
  339.                                      * Number-display gadgets
  340.                                      *)
  341.  
  342.   scArrows *          = tagBase+59; (* Specify size of arrows for
  343.                                      * scroller
  344.                                      *)
  345.  
  346.   mnMenu *            = tagBase+60; (* Pointer to Menu for use by
  347.                                      * LayoutMenuItems()
  348.                                      *)
  349.   mxSpacing *         = tagBase+61; (* Added to font height to
  350.                 * figure spacing between mx choices.  Use this instead
  351.                 * of layoutaSpacing for mx gadgets.
  352.                 *)
  353.  
  354. (* New to V37 GadTools.  Ignored by GadTools V36 *)
  355.   fullMenu *        = tagBase+62; (* Asks CreateMenus() to
  356.                 * validate that this is a complete menu structure
  357.                 *)
  358.   secondaryError *  = tagBase+63; (* tiData is a pointer
  359.                 * to a ULONG to receive error reports from CreateMenus()
  360.                 *)
  361.   underscore *        = tagBase+64; (* tiData points to the symbol
  362.                 * that preceeds the character you'd like to underline in a
  363.                 * gadget label
  364.                 *)
  365.   stEditHook *        = tagBase+55; (* String EditHook *)
  366.   inEditHook * = stEditHook;           (* Same thing, different name,
  367.                 * just to round out integerKind gadgets
  368.                 *)
  369.  
  370. (* New to V39 GadTools.  Ignored by GadTools V36 and V37 *)
  371.   mnCheckmark *    = tagBase+65;  (* data is checkmark img to use *)
  372.   mnAmigaKey *     = tagBase+66;  (* data is Amiga-key img to use *)
  373.   mnNewLookMenus * = tagBase+67;  (* data is boolean *)
  374.  
  375. (* New to V39 GadTools.  Ignored by GadTools V36 and V37.
  376.  * Set to TRUE if you want the checkbox or mx image scaled to
  377.  * the gadget width/height you specify.  Defaults to FALSE,
  378.  * for compatibility.
  379.  *)
  380.   cbScaled *        = tagBase+68;  (* data is boolean *)
  381.   mxScaled *        = tagBase+69;  (* data is boolean *)
  382.  
  383.   paNumColors *     = tagBase+70;  (* Number of colors in palette *)
  384.  
  385.   mxTitlePlace *    = tagBase+71;  (* Where to put the title *)
  386.  
  387.   txFrontPen *      = tagBase+72;  (* Text color in textKind gad *)
  388.   txBackPen *       = tagBase+73;  (* Bgrnd color in textKind gad *)
  389.   txJustification * = tagBase+74;  (* See j#? constants *)
  390.  
  391.   nmFrontPen *      = tagBase+72;  (* Text color in numberKind gad *)
  392.   nmBackPen *       = tagBase+73;  (* Bgrnd color in numberKind gad *)
  393.   nmJustification * = tagBase+74;  (* See j#? constants *)
  394.   nmFormat *        = tagBase+75;  (* Formatting string for number *)
  395.   nmMaxNumberLen *  = tagBase+76;  (* Maximum length of number *)
  396.  
  397.   bbFrameType *     = tagBase+77;  (* defines what kind of boxes
  398.                                     * DrawBevelBox() renders. See
  399.                                     * the bbft#? constants for
  400.                                     * possible values
  401.                                     *)
  402.  
  403.   lvMakeVisible *   = tagBase+78;  (* Make this item visible *)
  404.   lvItemHeight *    = tagBase+79;  (* Height of an individual item *)
  405.  
  406.   slMaxPixelLen *   = tagBase+80;  (* Max pixel size of level display *)
  407.   slJustification * = tagBase+81;  (* how should the level be displayed *)
  408.  
  409.   paColorTable *    = tagBase+82;  (* colors to use in palette *)
  410.  
  411.   lvCallBack *      = tagBase+83;  (* general-purpose listview call back *)
  412.   lvMaxPen *        = tagBase+84;  (* maximum pen number used by call back *)
  413.  
  414.   txClipped *       = tagBase+85;  (* make a textKind clip text *)
  415.   nmClipped *       = tagBase+85;  (* make a numberKind clip text *)
  416.  
  417. (* Old definition, now obsolete: *)
  418.   reserved0 *       = stEditHook;
  419.  
  420. (*------------------------------------------------------------------------*)
  421.  
  422. (* Justification types for txJustification and nmJustification tags *)
  423.   jLeft * = 0;
  424.   jRight * = 1;
  425.   jCenter * = 2;
  426.  
  427. (*------------------------------------------------------------------------*)
  428.  
  429. (* Bevel box frame types for bbFrameType tag *)
  430.   bbftButton * = 1;         (* Standard button gadget box *)
  431.   bbftRidge * = 2;          (* Standard string gadget box *)
  432.   bbftIconDropBox * = 3;    (* Standard icon drop box     *)
  433.  
  434. (* -----------------------------------------------------------------------*)
  435.  
  436. CONST
  437.  
  438. (*  Typical suggested spacing between "elements": *)
  439.   interWidth *      = 8;
  440.   interHeight *     = 4;
  441.  
  442. (* -----------------------------------------------------------------------*)
  443.  
  444. CONST
  445.  
  446. (*  "NWay" is an old synonym for cycle gadgets *)
  447.   nWAYKind *     = cycleKind;
  448.   nWAYIDCMP *    = cycleIdcmp;
  449.   nwLabels *     = cyLabels;
  450.   nwActive *     = cyActive;
  451.  
  452.  
  453. (*------------------------------------------------------------------------*)
  454.  
  455. (* These two definitions are obsolete, but are here for backwards
  456.  * compatibility.  You never need to worry about these:
  457.  *)
  458.   gadToolBit * = 15;
  459. (* Use this mask to isolate the user part: *)
  460.   gadToolMask * = -{gadToolBit};
  461.  
  462. (*------------------------------------------------------------------------*)
  463.  
  464. (* These definitions are for the LV_CallBack tag *)
  465.  
  466. (* The different types of messages that a listview callback hook can see *)
  467.   lvDraw * = 0202H;            (* draw yourself, with state *)
  468.  
  469. (* Possible return values from a callback hook *)
  470.   lvcbOk * = 0;                 (* callback understands this message type    *)
  471.   lvcbUnknown * = 1;            (* callback does not understand this message *)
  472.  
  473. (* states for LVDrawMsg.state *)
  474.   lvrNormal * = 0;              (* the usual                 *)
  475.   lvrSelected * = 1;            (* for selected gadgets      *)
  476.   lvrNormalDisabled * = 2;               (* for disabled gadgets      *)
  477.   lvrSelectedDisabled * = 8;             (* disabled and selected     *)
  478.  
  479. TYPE
  480.  
  481. (* structure of lvDraw messages, object is an Exec.NodePtr *)
  482.   LVDrawMsg * = RECORD
  483.     methodID * : E.ULONG;        (* lvDraw                    *)
  484.     rastPort * : G.RastPortPtr;  (* where to render to        *)
  485.     drawInfo * : I.DrawInfoPtr;  (* useful to have around     *)
  486.     bounds *   : G.Rectangle;    (* limits of where to render *)
  487.     state *    : E.ULONG;        (* how to render             *)
  488.   END;
  489.  
  490.  
  491. (**-- Library Base variable --------------------------------------------*)
  492.  
  493. TYPE
  494.  
  495.   GadToolsBasePtr * = CPOINTER TO GadToolsBase;
  496.   GadToolsBase * = RECORD (E.Library) END;
  497.  
  498. CONST
  499.  
  500.   name * = "gadtools.library";
  501.  
  502. VAR
  503.  
  504.   base * : GadToolsBasePtr;
  505.  
  506.  
  507. (**-- Library Functions ------------------------------------------------*)
  508.  
  509. (*
  510. **      $VER: gadtools_protos.h 39.2 (24.3.92)
  511. *)
  512.  
  513. (* --- functions in V36 or higher (distributed as Release 2.0) ---*)
  514.  
  515. (* Gadget Functions *)
  516.  
  517. LIBCALL (base : GadToolsBasePtr) CreateGadgetA*
  518.   ( kind     [0] : E.ULONG;
  519.     gad      [8] : I.GadgetPtr;
  520.     VAR ng   [9] : NewGadget;
  521.     taglist [10] : ARRAY OF U.TagItem )
  522.   : I.GadgetPtr;
  523.   -30;
  524. LIBCALL (base : GadToolsBasePtr) CreateGadget*
  525.   ( kind     [0]   : E.ULONG;
  526.     gad      [8]   : I.GadgetPtr;
  527.     VAR ng   [9]   : NewGadget;
  528.     taglist [10].. : U.Tag )
  529.   : I.GadgetPtr;
  530.   -30;
  531. LIBCALL (base : GadToolsBasePtr) FreeGadgets*
  532.   ( gad [8] : I.GadgetPtr );
  533.   -36;
  534. LIBCALL (base : GadToolsBasePtr) SetGadgetAttrsA*
  535.   ( VAR gad  [8] : I.Gadget;
  536.     win      [9] : I.WindowPtr;
  537.     req     [10] : I.RequesterPtr;
  538.     taglist [11] : ARRAY OF U.TagItem );
  539.   -42;
  540. LIBCALL (base : GadToolsBasePtr) SetGadgetAttrs*
  541.   ( VAR gad  [8]   : I.Gadget;
  542.     win      [9]   : I.WindowPtr;
  543.     req     [10]   : I.RequesterPtr;
  544.     taglist [11].. : U.Tag );
  545.   -42;
  546.  
  547. (* Menu functions *)
  548.  
  549. LIBCALL (base : GadToolsBasePtr) CreateMenusA*
  550.   ( newmenu [8] : ARRAY OF NewMenu;
  551.     taglist [9] : ARRAY OF U.TagItem )
  552.   : I.MenuPtr;
  553.   -48;
  554. LIBCALL (base : GadToolsBasePtr) CreateMenus*
  555.   ( newmenu [8]   : ARRAY OF NewMenu;
  556.     taglist [9].. : U.Tag )
  557.   : I.MenuPtr;
  558.   -48;
  559. LIBCALL (base : GadToolsBasePtr) CreateMenusAB*
  560.   ( newmenu [8] : NewMenuPtr;
  561.     taglist [9] : ARRAY OF U.TagItem )
  562.   : I.MenuPtr;
  563.   -48;
  564. LIBCALL (base : GadToolsBasePtr) CreateMenusB*
  565.   ( newmenu [8]   : NewMenuPtr;
  566.     taglist [9].. : U.Tag )
  567.   : I.MenuPtr;
  568.   -48;
  569. LIBCALL (base : GadToolsBasePtr) FreeMenus*
  570.   ( menu [8] : I.MenuPtr );
  571.   -54;
  572. LIBCALL (base : GadToolsBasePtr) LayoutMenuItemsA*
  573.   ( firstitem [8] : I.MenuItemPtr;
  574.     vi        [9] : VisualInfo;
  575.     taglist  [10] : ARRAY OF U.TagItem )
  576.   : BOOLEAN;
  577.   -60;
  578. LIBCALL (base : GadToolsBasePtr) LayoutMenuItems*
  579.   ( firstitem [8]   : I.MenuItemPtr;
  580.     vi        [9]   : VisualInfo;
  581.     taglist  [10].. : U.Tag )
  582.   : BOOLEAN;
  583.   -60;
  584. LIBCALL (base : GadToolsBasePtr) LayoutMenusA*
  585.   ( firstmenu [8] : I.MenuPtr;
  586.     vi        [9] : VisualInfo;
  587.     taglist  [10] : ARRAY OF U.TagItem )
  588.   : BOOLEAN;
  589.   -66;
  590. LIBCALL (base : GadToolsBasePtr) LayoutMenus*
  591.   ( firstmenu [8]   : I.MenuPtr;
  592.     vi        [9]   : VisualInfo;
  593.     taglist  [10].. : U.Tag )
  594.   : BOOLEAN;
  595.   -66;
  596.  
  597. (* Misc Event-Handling Functions *)
  598.  
  599. LIBCALL (base : GadToolsBasePtr) GetIMsg*
  600.   ( iport [8] : E.MsgPortPtr )
  601.   : I.IntuiMessagePtr;
  602.   -72;
  603. LIBCALL (base : GadToolsBasePtr) ReplyIMsg*
  604.   ( imsg [9] : I.IntuiMessagePtr );
  605.   -78;
  606. LIBCALL (base : GadToolsBasePtr) RefreshWindow*
  607.   ( win [8] : I.WindowPtr;
  608.     req [9] : I.RequesterPtr );
  609.   -84;
  610. LIBCALL (base : GadToolsBasePtr) BeginRefresh*
  611.   ( win [8] : I.WindowPtr );
  612.   -90;
  613. LIBCALL (base : GadToolsBasePtr) EndRefresh*
  614.   ( win      [8] : I.WindowPtr;
  615.     complete [0] : E.LBOOL );
  616.   -96;
  617. LIBCALL (base : GadToolsBasePtr) FilterIMsg*
  618.   ( imsg [9] : I.IntuiMessagePtr )
  619.   : I.IntuiMessagePtr;
  620.   -102;
  621. LIBCALL (base : GadToolsBasePtr) PostFilterIMsg*
  622.   ( imsg [8] : I.IntuiMessagePtr )
  623.   : I.IntuiMessagePtr;
  624.   -108;
  625. LIBCALL (base : GadToolsBasePtr) CreateContext*
  626.   (  VAR glistptr [8] : I.GadgetPtr )
  627.   : I.GadgetPtr;
  628.   -114;
  629.  
  630. (* Rendering Functions *)
  631.  
  632. LIBCALL (base : GadToolsBasePtr) DrawBevelBoxA*
  633.   ( rport   [8] : G.RastPortPtr;
  634.     left    [0] : LONGINT;
  635.     top     [1] : LONGINT;
  636.     width   [2] : LONGINT;
  637.     height  [3] : LONGINT;
  638.     taglist [9] : ARRAY OF U.TagItem );
  639.   -120;
  640. LIBCALL (base : GadToolsBasePtr) DrawBevelBox*
  641.   ( rport   [8]   : G.RastPortPtr;
  642.     left    [0]   : LONGINT;
  643.     top     [1]   : LONGINT;
  644.     width   [2]   : LONGINT;
  645.     height  [3]   : LONGINT;
  646.     taglist [9].. : U.Tag );
  647.   -120;
  648.  
  649. (* Visuals Functions *)
  650.  
  651. LIBCALL (base : GadToolsBasePtr) GetVisualInfoA*
  652.   ( screen  [8] : I.ScreenPtr;
  653.     taglist [9] : ARRAY OF U.TagItem )
  654.   : VisualInfo;
  655.   -126;
  656. LIBCALL (base : GadToolsBasePtr) GetVisualInfo*
  657.   ( screen  [8]   : I.ScreenPtr;
  658.     taglist [9].. : U.Tag )
  659.   : VisualInfo;
  660.   -126;
  661. LIBCALL (base : GadToolsBasePtr) FreeVisualInfo*
  662.   ( vi [8] : VisualInfo );
  663.   -132;
  664.  
  665. (*--- functions in V39 or higher (Release 3) ---*)
  666.  
  667. LIBCALL (base : GadToolsBasePtr) GetGadgetAttrsA *
  668.   ( gad      [8] : I.GadgetPtr;
  669.     win      [9] : I.WindowPtr;
  670.     req     [10] : I.RequesterPtr;
  671.     taglist [11] : ARRAY OF U.TagItem )
  672.   : LONGINT;
  673.   -174;
  674. LIBCALL (base : GadToolsBasePtr) GetGadgetAttrs *
  675.   ( gad      [8]  : I.GadgetPtr;
  676.     win      [9]  : I.WindowPtr;
  677.     req     [10]  : I.RequesterPtr;
  678.     taglist [11]..: U.Tag )
  679.   : LONGINT;
  680.   -174;
  681.  
  682.  
  683. (**-- C Macros defined as procedures -----------------------------------*)
  684. (** $L+ Absolute long addressing for globals *)
  685.  
  686. (*  A UserData pointer can be associated with each Menu and MenuItem structure.
  687.     The CreateMenus() call allocates space for a UserData after each
  688.     Menu or MenuItem (header, item or sub-item).  You should use the
  689.     gtMenuUSERDATA() or gtMenuitemUSERDATA() macro to extract it. *)
  690.  
  691. (**-----------------------------------*)
  692. PROCEDURE MenuUserData * (menu : I.MenuPtr) : E.APTR;
  693.  
  694. BEGIN (* MenuUserData *)
  695.   RETURN SYS.VAL (E.APTR, SYS.VAL (LONGINT, menu) + SIZE (I.Menu))
  696. END MenuUserData;
  697.  
  698. (**-----------------------------------*)
  699. PROCEDURE MenuItemUserData * (menuitem : I.MenuItemPtr) : E.APTR;
  700.  
  701. BEGIN (* MenuItemUserData *)
  702.   RETURN
  703.     SYS.VAL (E.APTR, SYS.VAL (LONGINT, menuitem) + SIZE (I.MenuItem))
  704. END MenuItemUserData;
  705.  
  706. (**-- Library Base variable --------------------------------------------*)
  707. (** $L- Address globals through A4 *)
  708.  
  709.  
  710. (**-----------------------------------*)
  711. PROCEDURE* CloseLib ();
  712.  
  713. BEGIN (* CloseLib *)
  714.   IF base # NIL THEN E.base.CloseLibrary (base) END
  715. END CloseLib;
  716.  
  717. (**-----------------------------------*)
  718. PROCEDURE OpenLib * (mustOpen : BOOLEAN);
  719.  
  720. BEGIN (* OpenLib *)
  721.   IF base = NIL THEN
  722.     base :=
  723.       SYS.VAL
  724.         ( GadToolsBasePtr,
  725.           E.base.OpenLibrary (name, E.libraryMinimum));
  726.     IF base # NIL THEN SYS.SETCLEANUP (CloseLib)
  727.     ELSIF mustOpen THEN HALT (100)
  728.     END;
  729.   END;
  730. END OpenLib;
  731.  
  732.  
  733. BEGIN
  734.   base := NIL
  735. END GadTools.
  736.